//
//  SpotBoottomView.swift
//  swiftProject
//
//  Created by ZhangSai on 2021/7/2.
//

import UIKit

protocol SpotBoottomViewDelegate:class {
    func SpotBoottomViewClickedType(clickType:SpotInfoCellType)
}

class SpotBoottomView: UIView {

    weak var delegate:SpotBoottomViewDelegate?

    @IBOutlet weak var printBtn: UIButton!
    @IBOutlet weak var valueLab: UILabel!
    @IBOutlet weak var titleLab: UILabel!
    @IBOutlet weak var selectBtn: UIButton!

    override func awakeFromNib() {
        super.awakeFromNib()
        self.titleLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_estimate)
        selectBtn.setTitle(ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_particulars), for: .normal)
        printBtn.setTitle(ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_placeOrder), for: .normal)
        
        selectBtn.titleEdgeInsets = UIEdgeInsets(top: 0, left: -(selectBtn.imageView?.image?.size.width ?? 0.0), bottom: 0, right: selectBtn.imageView?.image?.size.width ?? 0.0)
        selectBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: selectBtn.titleLabel?.bounds.size.width ?? 0.0, bottom: 0, right: -(selectBtn.titleLabel?.bounds.size.width ?? 0.0))
        printBtn.setTitleColor(UIColor.init(hexString: "#FFFFFF"), for: .normal)
    }
    
    
    @IBAction func clickPrintBtn(_ sender: UIButton) {
        if sender.titleLabel?.text == ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_placeOrder) {
            delegate?.SpotBoottomViewClickedType(clickType: SpotInfoCellType.Spot_Print_Type)
        } else {
            delegate?.SpotBoottomViewClickedType(clickType: SpotInfoCellType.Spot_Edit_Type)
        }
    }
    
    @IBAction func clickSelectBtn(_ sender: UIButton) {
        delegate?.SpotBoottomViewClickedType(clickType: SpotInfoCellType.Spot_ShowDetail_Type)
    }

  

}
